package 牛客.动态规划;

import java.util.Arrays;

public class 力扣674最长连续递增序列 {
    //注意和 300. 最长递增子序列的区别
    //动态规划
    public int findLengthOfLCIS(int[] nums) {
        if (nums.length<2) {
            return 1;
        }
        int[] dp=new int[nums.length];
        //dp[i] 代表从 0-i下标的元素，最长连续递增子序列的长度
        Arrays.fill(dp,1);

        int res=0;
        for (int i = 1; i <nums.length ; i++) {
            if (nums[i]>nums[i-1]) {
                dp[i]=dp[i-1]+1;
            }
            if (dp[i]>res) {
                res=dp[i];
            }
        }
        return res;
    }

    public int findLengthOfLCIS1(int[] nums) {
        //贪心算法
        if (nums.length<0) {
            return 0;
        }
        int res=1;
        int count=1;

        for (int i = 1; i <nums.length ; i++) {
            if (nums[i]>nums[i-1]) {
                count++;
            }else {
                count=1;
            }
            if (res<count) {
                res=count;
            }
        }
        return res;
    }
}
